﻿using System;
using System.Collections.Generic;
using System.Data;

namespace ALDIOrganizer
{
    public static class ExtensionMethods
    {
        

        public static bool IsShut(this SpecialDayStatus status)
        {
            return ((status & SpecialDayStatus.Shut) != 0);
        }

        public static bool IsInventory(this SpecialDayStatus status)
        {
            return ((status & SpecialDayStatus.Inventory) != 0);
        }
        
        
        #region extending DataRow class!
        
        

        

        public static void DescribeAllContracts(this OrderedEnumerableRowCollection<DataRow> drc)
        {
            var i = 0;
            DataRow previous = null;
            foreach (var row in drc)
            {
                if (i++ == 0)
                {
                    row[8] = row.FullDescription(true, true, true);
                }
                else
                {
                    var role = (row[4] != previous[4]);
                    var hours = (row[5] != previous[5]);
                    var hols = (row[6] != previous[6]);
                    row[8] = row.FullDescription(role, hours, hols);
                }
                previous = row;
            }
        }

        public static void DescribeAllHolidays(this EnumerableRowCollection<DataRow> drh)
        {
            foreach (var row in drh)
            {
                var startDate = (DateTime)row[2];
                var endDate = (DateTime)row[3];
                
                
                // displayColumn
                row[7] =    startDate.ToShortDateString() +
                            " - " +
                            endDate.ToShortDateString();
            }
        }

        public static void AddAsManyAsCount(this List<Style> list, Style colour)
        {
            var howMany = list.Count;
            for (var i = 0; i < howMany; i++)
            {
                list.Add(colour);
            }
        }
        


        #endregion




    }
}
